#include<iostream>
using namespace std;

const int N=30;
char l[N], r[N];
int head, sign;

void dfs(char num)
{
	cout<<num;
	int x=num-'a'+1;
	if(l[x]!='*')dfs(l[x]);
	if(r[x]!='*')dfs(r[x]);
}
int main()
{
	int n;
	cin>>n;
	while(n--)
	{
		char a,b,c;
		cin>>a;
		int x=a-'a'+1;
		if(!sign) 
		{
			head=x;
			sign=1;
		}
		cin>>l[x]>>r[x];
		
	}
	dfs(head-1+'a');
	return 0;
}
